package com.sinosoft.perfect.system._theme.service;

import java.sql.SQLException;
import java.util.List;

import com.sinosoft.perfect.system._.po.TTheme;
import com.sinosoft.perfect.system._.util.Producer;
import com.sinosoft.perfect.system._theme.dao.IThemeDAO;

public class ThemeServiceImpl implements IThemeService {

	private IThemeDAO themeDAO;

	public void setThemeDAO(IThemeDAO themeDAO) {
		this.themeDAO = themeDAO;
	}

	@Override
	public void deleteTThemeByPK(TTheme ttheme) throws SQLException {
		themeDAO.deleteTThemeByPK(ttheme);
	}

	@Override
	public String insertByTTheme(TTheme ttheme) throws SQLException {
		String id = Producer.generateIdOfTen();
		ttheme.setThemeId(id);
		ttheme.setThemeDefault("0");
		ttheme.setStatus("1");
		themeDAO.insertByTTheme(ttheme);
		return id;
	}

	@Override
	public List<TTheme> selectByTTheme(TTheme ttheme) throws SQLException {
		return themeDAO.selectByTTheme(ttheme);
	}

	@Override
	public void updateTThemeByPK(TTheme ttheme) throws SQLException {
		themeDAO.updateTThemeByPK(ttheme);
	}

	@Override
	public void updateTThemeDefaultThemeAndAnotherNormal(TTheme ttheme)
			throws SQLException {
		TTheme t = new TTheme();
		t.setThemeDefault("0");
		themeDAO.updateTThemeByPK(t);
		themeDAO.updateTThemeByPK(ttheme);
	}

}
